const Router = require('@koa/router')

const { ADMIN_KEY } = require('../env')

const PublicRouter = require('./public/common')
const PublicBizRouter = require('./public/biz') // 业务接口，大部分是聚合原始数据
const PublicMapWay = require('./public/map-way') // 主功能：路径查找


const ExternalRouter = require('./external') // 第三方接口，微信登录/战网API
const GameDataRouter = require('./game-data') // wow 原始数据结构
const MythicDungeon = require('./mythic-dungeon') // Mythic+ 地下城
const AffixRouter = require('./affix') // Mythic+ 词缀
const SpellRouter = require('./spell') // 法术
const JIRouter = require('./journal-instance') // 副本
const JERouter = require('./journal-encounter') // 首领
const ItemRouter = require('./item') // 物品
const MapRouter = require('./map') // 地图
const MapWayRouter = require('./map-way') // 起始地图


// /test health check
const router = new Router()
router.get('/', function (ctx) {
  ctx.body = ADMIN_KEY
})

module.exports = (app) => {
  app.use(router.routes())
  app.use(PublicRouter.routes(), PublicRouter.allowedMethods())
  app.use(PublicBizRouter.routes(), PublicBizRouter.allowedMethods())
  app.use(PublicMapWay.routes(), PublicMapWay.allowedMethods())

  app.use(ExternalRouter.routes(), ExternalRouter.allowedMethods())
  app.use(GameDataRouter.routes(), GameDataRouter.allowedMethods())

  app.use(MythicDungeon.routes(), MythicDungeon.allowedMethods())
  app.use(AffixRouter.routes(), AffixRouter.allowedMethods())
  app.use(SpellRouter.routes(), SpellRouter.allowedMethods())
  app.use(JIRouter.routes(), JIRouter.allowedMethods())
  app.use(JERouter.routes(), JERouter.allowedMethods())
  app.use(ItemRouter.routes(), ItemRouter.allowedMethods())
  app.use(MapRouter.routes(), MapRouter.allowedMethods())
  app.use(MapWayRouter.routes(), MapWayRouter.allowedMethods())
}
